import * as actions from '../actions/index';

// 页面初始化数据
import intl from '../../../../../../../../../locale';

export const initialState = {
  allBranches: [],
  defaultBranch: '',
  protectedBranches: [],
  isLoadingTable: false,
  isPostingDefaultBranch: false,
  isUpdatingRecord: false,
  integration_service_setting: {},
  isLoadingServices: true,
  roles: [
    {
      label: intl.get({
        id: 'code-assets.settingsBranches.reducers.Administrator',
        defaultMessage: '管理员',
      }),
      value: 40,
    },

    {
      label: intl.get({
        id: 'code-assets.settingsBranches.reducers.Developers',
        defaultMessage: '开发者',
      }),
      value: 30,
    },
  ],

  record: {},
  isModalOpen: false,
  modalType: 'edit',
  goServiceSetting: false,
  // 添加测试项完成状态
  isBranchCompleted: true,
  flowBuildNames: [],
};

const defaultAction = {
  type: 'doNothing',
};

export default function index(state = initialState, action = defaultAction) {
  switch (action.type) {
    case actions.UPDATE_DATA:
      return { ...state, ...action.data };
    default:
      return state;
  }
}
